Skip to content

docs: add CLAUDE.md architecture guide#346

Merged
jfberry merged 2 commits intomainfrom
docs/claude-md
Mar 21, 2026
Merged

docs: add CLAUDE.md architecture guide#346
jfberry merged 2 commits intomainfrom
docs/claude-md

Conversation

@jfberry
Copy link
Copy Markdown
Collaborator

@jfberry jfberry commented Mar 20, 2026

Summary

Adds a CLAUDE.md file — a structured architecture guide that AI coding assistants (Claude Code, Copilot, Cursor, etc.) automatically read when working on this repository.

Why CLAUDE.md?

Golbat has significant architectural complexity that isn't obvious from reading individual files:

  • The two-level spatial query pattern (R-tree + lookup cache) that avoids entity locks during scans — a developer unfamiliar with this could easily introduce lock contention by querying entities directly in a scan loop
  • Four distinct record access patterns (Peek, ReadOnly, ForUpdate, GetOrCreate) with different snapshotting and DB fallback behavior — using the wrong one causes subtle bugs (missing webhook diffs, unnecessary DB hits, deadlocks)
  • Write-behind queue coalescing with pokemon delay — understanding why wild pokemon have a 30s write delay is essential context for anyone touching the save path
  • Lock ordering constraints — the pokestop↔gym conversion pattern requires releasing one lock before acquiring another, which isn't self-documenting
  • Fort tracker stale detection — the S2 cell-based lifecycle tracking has non-obvious interactions with the cache eviction and R-tree systems

Without this context, contributors (human or AI) tend to:

  1. Re-lock entities that are already locked, causing deadlocks
  2. Use ReadOnly when ForUpdate is needed, losing webhook change detection
  3. Query full entities inside scan loops instead of using the lookup cache
  4. Miss the implications of the pokemon write delay when debugging data freshness issues

The guide covers: raw message processing pipeline, entity model patterns, caching (sharded vs TTL), locking model, write-behind queues, webhooks, fort tracking, and the R-tree/DNF spatial query system.

Test plan

  • Verified accuracy against current codebase
  • Review by maintainers for any inaccuracies or missing context

🤖 Generated with Claude Code

jfberry and others added 2 commits March 20, 2026 16:22
Comprehensive guide covering raw message processing, entity model,
caching (sharded vs TTL), locking model (4 access patterns), write-behind
queues with pokemon delay, webhooks, fort tracker, and the two-level
R-tree + lookup cache architecture for spatial/DNF queries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jfberry jfberry merged commit e76d07a into main Mar 21, 2026
4 checks passed
@Fabio1988 Fabio1988 deleted the docs/claude-md branch March 21, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant